package org.lgiavedoni.android.franq.service.phone.sms;

import org.lgiavedoni.android.franq.core.contact.ContactPhone;
import org.lgiavedoni.android.franq.service.log.Logger;
import org.lgiavedoni.android.franq.service.phone.ContextService;

import android.telephony.SmsManager;

public class SMSService {

	public static final SMSService inst = new SMSService();
	private SmsManager smsManager;

	private SMSService() {
		if (ContextService.inst.isApplicationContextLoaded())
			smsManager = SmsManager.getDefault();
	}

	public void sendSMS(ContactPhone contactPhone, String message) {
		sendSMS(contactPhone.getNumber(), message);
	}

	public void sendSMS(String phoneNumber, String message) {
		Logger.inst.log("Sending message [to " + phoneNumber + ", text " + message + "]", Logger.LogLevel.INFO);
		// PendingIntent pi = PendingIntent.getActivity(this, 0,
		// new Intent(this, SMS.class), 0);
		if (smsManager != null)
			smsManager.sendTextMessage(phoneNumber, null, message, null, null);
	}

}
